﻿//
// © Algobox Ltd - Benn Eichhorn
//

namespace Algobox.Toolbox.Math
{
    /// <summary>
    /// A static implementation of System.Random pseudo random number generator
    /// </summary>
    public static class Random
    {
        static System.Random _random = new System.Random();

        public static int Next()
        {
            return _random.Next();
        }

        public static int Next(int maxValue)
        {
            return _random.Next(maxValue);
        }

        public static int Next(int minValue, int maxValue)
        {
            return _random.Next(minValue, maxValue);
        }

        public static void NextBytes(byte[] buffer)
        {
            _random.NextBytes(buffer);
        }

        public static double NextDouble()
        {
            return _random.NextDouble();
        }

        public static int RandomiseOrderQuantity(int quantity)
        {
            if (quantity >= 20 && quantity < 500)
                return quantity - 10 + _random.Next(0, 20);
            else if (quantity >= 500 && quantity < 1000)
                return quantity - 20 + _random.Next(0, 40);
            else if (quantity >= 1000 && quantity < 10000)
                return quantity - 50 + _random.Next(0, 100);
            else if (quantity >= 10000)
                return quantity - 100 + _random.Next(0, 200);
            return quantity;
        }

        public static uint RandomiseOrderQuantity(uint quantity)
        {
            if (quantity >= 20 && quantity < 500)
                return quantity - 10 + (uint)_random.Next(0, 20);
            else if (quantity >= 500 && quantity < 1000)
                return quantity - 20 + (uint)_random.Next(0, 40);
            else if (quantity >= 1000 && quantity < 10000)
                return quantity - 50 + (uint)_random.Next(0, 100);
            else if (quantity >= 10000)
                return quantity - 100 + (uint)_random.Next(0, 200);
            return quantity;
        }
    }
}
